<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" 
type="text/css" href="${pageContext.request.contextPath }/mc/css/index_love.css"></link>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/mc/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/mc/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript">
	function add() {
		$.post("${pageContext.request.contextPath}/add",$("#frm").serialize(),function(data){
			if (data.flag) {
				alert("编辑成功！")
				location="${pageContext.request.contextPath}/list";
			} else {
				alert("编辑失败！")

			}
		},'json')
	}
 </script>
<title>Insert title here</title>
</head>
<body>
	<form id="frm">
		<table>
			<tr>
				<td>用户名</td>
				<td><input type="text" name="cname" value="${lv.cname }">
					<input type="hidden" name="cid" value="${lv.cid }">
				</td>
			</tr>
			<tr>
				<td>手机号</td>
				<td><input type="text" name="cphone" value="${lv.cphone }"></td>
			</tr>
			<tr>
				<td>用户组</td>
				<td>
					<c:forEach items="${usList }" var="us">
						<c:set var="flag" value="0"></c:set>
						<c:forEach items="${lv.tids }" var="tid">
							<c:if test="${us.tid==tid }">
								<c:set var="flag" value="1"></c:set>
							</c:if>
						</c:forEach>
						<input type="checkbox" ${flag==1?'checked':'' } name="ids" value="${us.tid }">${us.tname }
					</c:forEach>
				</td>
			</tr>
			<tr>
				<td></td>
				<td><input type="button" onclick="add()" value="编辑"></td>
			</tr>
		</table>
	</form>	
</body>
</html>